***********************************************************************
* This files produces results from analysis 
* of the two-period panel on PR votes (Table 2)
* Michael Becher (michael.becher@ie.edu); March 13, 2025
***********************************************************************


*log using an_votes_panel_log, replace

use VotesPanel, clear
xtset bnum year

******
*TABLE 2: Panel evidence
******


eststo clear
*Two-way fixed effects models
eststo: xtreg pr sector1 i.year, fe vce(cluster bnum)
*Add canton-specific trend
eststo: xtreg pr sector1 i.year i.knum#c.year, fe vce(cluster bnum)
*Add pre-trend agriculture
eststo: xtreg pr sector1 i.year c.agricgr_pre#c.year i.knum#c.year, fe vce(cluster bnum)
*Add time-varying census controls
eststo:  xtreg pr sector1 i.year poplog german protestant ethnofrac religfrac c.agricgr_pre#c.year i.knum#c.year, fe vce(cluster bnum)
estadd local Controls_D "X"
*Double selection lasso linear model for district controls:
*Possible cenus controls interacted and squared (always keep canton fixed effects and time trends)
local cvars "poplog german protestant ethnofrac religfrac"
local controls `cvars' c.(`cvars')# c.(`cvars')
eststo: dsregress pr sector1, controls((i.bnum2 i.year) `controls' c.agricgr_pre#c.year i.knum#c.year) cluster(bnum)
display e(controls_sel)	
estadd local Controls_I  "X"
esttab using "output/table2.tex", label r2 dep nocons replace ///
	keep(sector1) ///
	cells(b(star fmt(%15.2fc)) se(par fmt(%15.2fc))) ///
	star(* 0.05) ///
	stats(N, fmt(%15.0fc ) layout(@ @ @ @ @) ///
	labels("Observations")) ///
	collabels(none) mlabels("OLS" "OLS" "OLS" "OLS" "DSLR") ///
	mgroups("Vote for introduction of PR" , pattern(1 0 0 0) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
	
*log close
